Although the main purpose of making film is entertainment, not earning enough profit puts filmmakers in an awkward situation that makes it difficult to keep producing high-quality movies. One most popular quality metric is the score from Internet Movie Database (IMDb). Based on the movie metadata from IMDb, it would be interesting to analyze what makes a movie more successful than another, commercially and/or critically. So, the main goal of this project is to explore the IMDb dataset with focus on profit and IMDb score and present the findings in an intuitive and interactive way. And, if possible, to identify what features contribute to a highly rated/profitable film most significantly and try to predict a movie’s profitability.
These are the R packages required for this project.
library(tidyverse)
library(knitr)
library(plotly)
library(ggrepel)
library(DT)
library(tm)
library(openxlsx)
The dataset used in this project came from the IMDb 5000 Movie Dataset from Kaggle. It recorded information on more than 5000 movies across 66 countries from 1916 to 2016. The dataset is available in a csv format file and is of size 1MB. Note that the original dataset is replaced on Kaggle website, and therefore I cannot access the original one. The following link is where I sourced the same data from: https://www.kaggle.com/carolzhangdc/imdb-5000-movie-dataset (Yueming Zhang 2017). The data preparation part consists of the following tasks:
Import the data and show the dimension and names of all attributes of the data. WThere are 5043 movies recorded in this dataset, and each record has 28 attributes., including information such as Title of the movie, Name of the movie director, Country the movie was produced in, Budget of the movie (in USD), Profitability, and IMDB score for the movie.
## [1] 5043 28
## [1] "color" "director_name"
## [3] "num_critic_for_reviews" "duration"
## [5] "director_facebook_likes" "actor_3_facebook_likes"
## [7] "actor_2_name" "actor_1_facebook_likes"
## [9] "gross" "genres"
## [11] "actor_1_name" "movie_title"
## [13] "num_voted_users" "cast_total_facebook_likes"
## [15] "actor_3_name" "facenumber_in_poster"
## [17] "plot_keywords" "movie_imdb_link"
## [19] "num_user_for_reviews" "language"
## [21] "country" "content_rating"
## [23] "budget" "title_year"
## [25] "actor_2_facebook_likes" "imdb_score"
## [27] "aspect_ratio" "movie_facebook_likes"
Here is the preview the raw data.
In order to get the data ready for analysis, some tidying and cleansing works need to be done. First, unnecessary characters in the movie_title, genre and plot_keyword columns were removed.
Second, duplicates in the data in movie_title column were removed as they may affect later analysis. In total, 126 duplicate movies were removed.
## [1] 126
Third, columns that contain currency, such as the budget and gross, may cause problems in later analysis because a few countries were not converted to US dollars, including “South Korea”, “Japan”, “Thailand”, …, etc. Furthermore, given that all of them are converted to US dollars, we still need to consider the inflation, and this makes the problem even more complicated. Thus, only movies from USA were kept for profitability analysis.
## # A tibble: 4,917 x 4
## movie_title budget country gross
## <chr> <dbl> <chr> <int>
## 1 Lady Vengeance 4200000000 South Korea 211667
## 2 Fateless 2500000000 Hungary 195888
## 3 Princess Mononoke 2400000000 Japan 2298191
## 4 Steamboy 2127519898 Japan 410388
## 5 Akira 1100000000 Japan 439162
## 6 Godzilla 2000 1000000000 Japan 10037390
## 7 Kabhi Alvida Naa Kehna 700000000 India 3275443
## 8 Tango 700000000 Spain 1687311
## 9 Kites 600000000 India 1602466
## 10 Red Cliff 553632000 China 626809
## # ... with 4,907 more rows
Then, an new column profitable was added to indicate if a movie is profitable, ‘1’ means profitable (that is, profit \(>\) budget). As this involving both gross and budget columns, only movies from USA have non-empty value for this column. This version of data is also saved to an Excel file for people who want to focus only on USA films.
Last, ragarding records that contain missing values, to keep the entire dataset as complete as possible, I decided to not remove any rows with missing data and to handle this issue for each individual analysis. For example, when doing genre-wise analysis, those without values for genre variables are excluded from the analysis.
Columns that contain most “NA” entries are gross, budget, and aspect_ratio.
## # A tibble: 30 x 2
## `Column Name` NA_Count
## <chr> <int>
## 1 gross 863
## 2 budget 484
## 3 aspect_ratio 326
## 4 title_year 106
## 5 director_facebook_likes 102
## 6 num_critic_for_reviews 49
## 7 actor_3_facebook_likes 23
## 8 num_user_for_reviews 21
## 9 duration 15
## 10 facenumber_in_poster 13
## # ... with 20 more rows
Finishing the cleaning process, check dimesnion and list columns names of the cleaned data. Then, save it to an csv file.
## [1] 4917 30
## [1] "color" "director_name"
## [3] "num_critic_for_reviews" "duration"
## [5] "director_facebook_likes" "actor_3_facebook_likes"
## [7] "actor_2_name" "actor_1_facebook_likes"
## [9] "gross" "genres"
## [11] "actor_1_name" "movie_title"
## [13] "num_voted_users" "cast_total_facebook_likes"
## [15] "actor_3_name" "facenumber_in_poster"
## [17] "plot_keywords" "movie_imdb_link"
## [19] "num_user_for_reviews" "language"
## [21] "country" "content_rating"
## [23] "budget" "title_year"
## [25] "actor_2_facebook_likes" "imdb_score"
## [27] "aspect_ratio" "movie_facebook_likes"
## [29] "genres_new" "plot_keywords_new"
Note that, after all the preprocessing, there are 3768 rows that do not have any missing value and they are also saved to an Excel sheet.
## [1] 3700
The following table lists the name, type, and description of each variable in the dataset.
| Name | Type | Description |
|---|---|---|
| color | character | Colorization: Color or Black and White |
| director_name | character | Name of the director |
| num_critic_for_reviews | integer | Number of Critical Reviews |
| duration | integer | Duration of the movie in Minutes |
| director_facebook_likes | integer | Number of FB Page Likes of Director |
| actor_3_facebook_likes | integer | Number of FB Page Likes of Actor No.3 |
| actor_2_name | character | Name of Actor No.2 |
| actor_1_facebook_likes | integer | Number of FB Page Likes of Actor No.1 |
| gross | integer | Gross Earned in US Dollars |
| genres | character | Classification: Action, Comedy, Drama, …, etc. |
| actor_1_name | character | Name of Actor No.1 |
| movie_title | character | Title of the Movie |
| num_voted_users | integer | Number of Voted Users on IMDB |
| cast_total_facebook_likes | integer | Total FB Page Likes of of the Entire Cast |
| actor_3_name | character | Name of Actor No.3 |
| facenumber_in_poster | integer | Number of the Actors Featured in the Movie Poster |
| plot_keywords | character | Keywords Describing the Plot |
| movie_imdb_link | character | IMDB Link of the Movie |
| num_user_for_reviews | integer | Number of Users who Reviewed the Movie |
| language | character | Language of the movie: English, French, Chinese, …, etc. |
| country | character | Country where the Movie was Produced |
| content_rating | character | Content rating |
| budget | double | Budget in US Dollars |
| title_year | integer | Year of Release |
| actor_2_facebook_likes | integer | Number of FB Page Likes of Actor No.2 |
| imdb_score | double | IMDB Score on a Scale of 1 to 10 |
| aspect_ratio | double | Aspect Ratio |
| movie_facebook_likes | integer | Number of FB Page Likes of the Film |
| genres_new | character | Edited genres |
| plot_keywords_new | character | Edited plot_keywords |
The analysis involves four main aspects: Genre, Country, IMDB score, and how they relate to Profitability.
Since most of movies in this dataset were categorized as multiple genres, some preprocessing on the genres must be done before actually analyzing the data.
First, the document-term matrix for genres was constructed using the package “TM”.
## <<DocumentTermMatrix (documents: 4917, terms: 26)>>
## Non-/sparse entries: 14127/113715
## Sparsity : 89%
## Maximal term length: 11
## Weighting : term frequency (tf)
Then, the created document-term matrix was used to calculate frequency for each genre.
## # A tibble: 26 x 2
## genre count
## <chr> <dbl>
## 1 drama 2533
## 2 comedy 1847
## 3 thriller 1364
## 4 action 1113
## 5 romance 1084
## 6 adventure 888
## 7 crime 868
## 8 sci-fi 594
## 9 fantasy 583
## 10 horror 539
## # ... with 16 more rows
After preprocessing was done, we can start doing analysis about the genres data. First, we try to find which genres are used the most. By plotting distribution of genres frequency, we can see that the top 5 movie genres are “Drama”, “Comedy”, “Thriller”, “Action”, and “Romance”.
Now, we want to identify which genre tend to have higher profitability as well as ratings. As mentioned previously, this part involves movies only from USA due to the currency conversion issue.
First, we calculate the average budget, gross, and profit (= gross - budget) for each genre.
## # A tibble: 23 x 5
## genres_new mean_gross mean_budget mean_profit mean_imdb
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 Action 85881165. 70503681. 15377484. 6.24
## 2 Adventure 107588235. 80902013. 26686222. 6.41
## 3 Animation 120847003. 85607853. 35239151. 6.64
## 4 Biography 46089398. 29135662. 16953735. 7.10
## 5 Comedy 54540529. 35059454. 19481075. 6.14
## 6 Crime 44945166. 33948142. 10997025. 6.50
## 7 Documentary 14683626. 4021501. 10662126. 6.84
## 8 Drama 42460107. 29585071. 12875036. 6.72
## 9 Family 94310623. 64866065. 29444559. 6.19
## 10 Fantasy 90539880. 66073493. 24466387. 6.23
## # ... with 13 more rows
Then, we compared them using a grouped bar chart sorted by a descending order of the mean profit. From the plot, we can find a few things:
In this section, we tried to analyze what makes movies more successful in terms of the IMDb ratings.
First, to look at the basic central tendency (mean) and the variation in movie score, we plot a histogram of IMDb score along with several summary statistics. We can see that the mean IMDb Score is 6.4 and 90% of movies have a score between 8.0 and 4.6. IMDb scores follow a bell shaped distribution, and so a movie having a score \(> 8.1\) would be the top 5% movies in the world.
## imdb_score
## Min. :1.600
## 1st Qu.:5.900
## Median :6.600
## Mean :6.464
## 3rd Qu.:7.200
## Max. :9.300
## 5% 95%
## 4.6 8.0
Here is the IMDb score distribution.
Top 10 movies with highest IMDb score.
Top 10 directors with highest average IMDb score.
To understand the relationship between IMDB score, profit and budget, I first plotted a 3-Dimensional scatter plot using the popular visualization package “plotly” to try to have a big picture about it. The result is an interactive plot, which makes it easier for us to observe the relationship between them. As previously discussed, this analysis only includes movies from USA.
From the plot, we can see that movies with higher IMDb score tend to have higher profit and significant number of movies end up losing money. Intuitively, IMDB score and groos might be correlated as people are more willing to watch famous and highly-rated movies.
However, as people may be more interested in those films with huge commerical success, the top 30 profitable films were plotted as well as their gross and IMDb scores, where the vertical and the horizontal line refers to the median gross and the median IMDb score. Note that the bigger the point is, the more profit it has made. It follows that, when taking a closer look at relationship of these films with their IMDb ratings, there is little correlation found between them. This is as expected since most highly-rated films don’t do well on box office.
These are the top 30 movies with highest Profit, along with its profit and IMDb score. Note that the bigger a point is, the higher its IMDb score is. For movies with budget over 70 millions dollars, we can observe an upward trend close to linear, which can be inferred that bigger-budget movies tend to earn more profit. However, there’s a downward trend when the budget is less than 70 millions dollars. Having a closer look, I found most of these movies produced in the 80s or early 90s, and so, their true budget should be higher with inflation being taken into consideration.
Nonetheless, the profit earned does not give a whole picture about financial success of a movie throughout the years, so “Return on Investment (ROI)” is used to provide a different perspective about a movie’s profitability. The following graph shows top 30 highest Return on Investment movies of at least 10 millions dollars budget. As expected, films with smaller budget have higher ROI and the ROI decreases as the budget grows bigger. Yet, we can see that the ROIs for movies with over \(\$50M\) budget do not differ much.
Yueming Zhang. 2017. IMDB 5000 Movie Dataset | Kaggle. https://www.kaggle.com/carolzhangdc/imdb-5000-movie-dataset.